﻿using OnlineAuction.Business;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnlineAuction.Ajax
{
    public partial class UpdateFinishTime : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AuctionBO bo = new AuctionBO();
            string ConnectString = bo.GetConnection();
            string query;
            string ndate;
            //get auction id from client
            int aid = int.Parse(Request.QueryString["AuctionID"]);  
            SqlConnection conn = new SqlConnection(ConnectString);
            //update database
            conn.Open();
            ndate = DateTime.Now.AddSeconds(10).ToString("MM/dd/yyyy HH:mm:ss");
            query = "Update Auction Set TimeFinishAuction ='"+ndate+"' Where AuctionID=" + aid+ ")";
            SqlCommand cmd = new SqlCommand(query, conn);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
    }
}